<?php


namespace Modules\Cms\Http\Controllers\Web;
use Intervention\Image\ImageManagerStatic as Image;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Writer\PngWriter;
use App\Helpers\ViewHelpers;
use App\Http\Controllers\MyController;
use Modules\Cms\Http\Requests\ArticleCommentRequest;
use Modules\Cms\Models\Article;
use Modules\Cms\Models\ArticleCategory;
use Modules\Cms\Models\ArticleComment;
use Modules\Cms\Models\ArticleTag;
use Addons\Ads\Models\Ads;
use Illuminate\Http\Request;
use App\Models\UserInfo;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Response;
class DownController extends MyController
{
     public function downQrCode(Request $MyRequest){
        $url= $MyRequest->get('url', 0);
        $id= $MyRequest->get('id', 0);
        $writer = new PngWriter();
        $uid=Auth::check()?auth()->user()->id:0;
        $qrCode = QrCode::create(route('cms.single',['id'=>$id,'from'=>$uid]));  
        $result = $writer->write($qrCode);
        $img = Image::make($url);
        $img->insert($result->getString(),'bottom-right',60, 60); 
        return $img->response('jpg');
    }
     public function download()
    {
      return response()->download(url('/qrcode?url=http://img.daxue.ink/202207/10/xXBd60x99sauziMikr5WpqMJyMp8Hc0uxaHRUO1O.jpg'),'11.jpg');
         

    }

   
}